package com.xxx.store.controller;

import com.xxx.store.entity.Order;
import com.xxx.store.service.OrderService;
import com.xxx.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/orders")
public class OrderController extends BaseController{
    @Autowired
    private OrderService orderService;

    @RequestMapping("/create")
    public JsonResult<Order> create(Integer aid, Integer[] cids,HttpSession session){
        Order order = orderService.createOrder(aid, getUidFromSession(session), getUsernameFromSession(session), cids);
        return new JsonResult<>(OK,order);
    }
}
